home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / AppleScript / Development Tools / Sample Code / 7Edit / Pascal Sources / SVEditMain.p < prev    next >
Encoding:
Text File  |  1994-02-25  |  15.7 KB  |  663 lines  |  [TEXT/MPS ]

  1.  
  2. {[d-,h-,k+,o=100,q+,r+,rec+,t=2,u+,:+,j=15/20/25/30/35/40/45/50/57/1$]} {Pasmat opts!}
  3.  
  4. PROGRAM SVEdit;
  5. (*
  6.     SVEditMain.p
  7.     
  8.     Version 3.0d8
  9.     
  10.     Copyright © SRL Data 1992, 1993
  11.     
  12.     All rights reserved
  13.     
  14.     Produced by : SRL Data
  15.     Originally Developed for UK.DTS
  16.  
  17. *)
  18.  
  19. {The main routines for the SVEdit example program}
  20.  
  21. {* This example is brought to you for the purposes of exploration and experimentation of
  22. System 7.0.  It is not intended to form the basis of your own programs- but try out the code-
  23. that's what it's there for *}
  24.  
  25. {System 7.0 specifics-:
  26.  
  27. We check the configuration on startup to see if we are running on a pre-7.0
  28. machine.    Much as we'd like to handle both environments in 7Edit, we thought
  29. exiting gracefully under pre-7.0 systems was the best solution.
  30.  
  31.  
  32. Notice the additions to the main event loop to support section events and the
  33. despatching of AppleEvents.
  34.  
  35.     New for 3.0d2 :
  36.     
  37.     21-Feb-92 : NH : Fix type into subscribers
  38.     26-Feb-92 : NH : ShowBorders grey when no window
  39.     27-Feb-92 : NH : Test menu and gCurrSection zapped
  40.      5-Mar-92 : NH : Create Publisher - event driven (ish)
  41.     27-Mar-92 : NH : Update menu status before MenuKey
  42.     
  43.     Changes for 3.0d5 :
  44.     
  45.     11-Aug-92 : NH : Quit via AppleEvent
  46.     21-Aug-92 : NH : Keystroke recording added
  47.                      Filing uses errors not booleans
  48. }
  49.  
  50.     USES MemTypes, QuickDraw, OSIntf, ToolIntf, Types, Traps, Menus, Packages, PPCToolbox, Editions,
  51.              Printing, AppleEvents, AEObjects, SVEditGlobals, SVEditUtils, SVEditions, SVAppleEvents,
  52.              SVEditWindow, SVEditFile;
  53.  
  54.         {-----------------------------------------------------------------------}
  55.         {*----------                         Standard Main routines                  --------------*}
  56.         {-----------------------------------------------------------------------}
  57.  
  58.         {$S Main}
  59.  
  60.     PROCEDURE MaintainCursor;
  61.  
  62.         VAR
  63.             pt                        : POINT;
  64.             wPtr                    : WindowPtr;
  65.             savePort            : GrafPtr;
  66.             theDoc                : DPtr;
  67.  
  68.         BEGIN
  69.             wPtr := FrontWindow;
  70.             IF Ours(wPtr) THEN
  71.                 BEGIN
  72.                     theDoc := DPtrFromWindowPtr(wPtr);
  73.                     GetPort(savePort);
  74.                     SetPort(wPtr);
  75.                     GetMouse(pt);
  76.                     IF (theDoc^.theText <> NIL) THEN
  77.                         IF PtinRect(pt, theDoc^.theText^^.viewRect) THEN
  78.                             SetCursor(editCursor)
  79.                         ELSE
  80.                             SetCursor(arrow)
  81.                     ELSE
  82.                         SetCursor(arrow);
  83.  
  84.                     IF theDoc^.theText <> NIL THEN
  85.                         TEIdle(theDoc^.theText);
  86.  
  87.                     SetPort(savePort);
  88.                 END;
  89.         END;
  90.  
  91.     {$S Main}
  92.  
  93.     PROCEDURE MaintainMenus;
  94.  
  95.         VAR
  96.             theDoc                : DPtr;
  97.             firstWindow   : WindowPtr;
  98.             currSection   : SectHandle;
  99.  
  100.         BEGIN
  101.             firstWindow := FrontWindow;
  102.             IF NOT (Ours(firstWindow)) THEN
  103.                 BEGIN
  104.                     EnableItem(myMenus[fileM], fmNew);
  105.                     EnableItem(myMenus[fileM], fmOpen);
  106.                     DisableItem(myMenus[fileM], fmClose);
  107.                     DisableItem(myMenus[fileM], fmSave);
  108.                     DisableItem(myMenus[fileM], fmSaveAs);
  109.                     DisableItem(myMenus[fileM], fmRevert);
  110.                     DisableItem(myMenus[fileM], fmPrint);
  111.                     DisableItem(myMenus[fileM], fmPageSetup);
  112.                     
  113.                     DisableItem(myMenus[editM],  cPublisher);
  114.                     DisableItem(myMenus[editM],  cSubscriber);
  115.                     DisableItem(myMenus[editM],  cOptions);
  116.                     DisableItem(myMenus[editM],  cBorders);
  117.                     
  118.                     IF firstWindow <> NIL THEN
  119.                         BEGIN
  120.                             EnableItem(myMenus[editM], undoCommand);
  121.                             EnableItem(myMenus[editM], cutCommand);
  122.                             EnableItem(myMenus[editM], copyCommand);
  123.                             EnableItem(myMenus[editM], pasteCommand);
  124.                             EnableItem(myMenus[editM], clearCommand);
  125.                         END;
  126.                 END
  127.             ELSE
  128.                 BEGIN
  129.                     theDoc := DPtrFromWindowPtr(firstWindow);
  130.                     EnableItem(myMenus[editM], pasteCommand);
  131.                     EnableItem(myMenus[editM], cBorders);
  132.                     EnableItem(myMenus[fileM], fmClose);
  133.                     EnableItem(myMenus[fileM], fmSaveAs);
  134.                     EnableItem(myMenus[fileM], fmPrint);
  135.                     EnableItem(myMenus[fileM], fmPageSetup);
  136.  
  137.                     IF (theDoc^.dirty) THEN
  138.                         EnableItem(myMenus[fileM], fmRevert)
  139.                     ELSE
  140.                         DisableItem(myMenus[fileM], fmRevert);
  141.                         
  142.                     IF ((theDoc^.dirty) AND (theDoc^.everSaved)) THEN
  143.                         EnableItem(myMenus[fileM], fmSave)
  144.                     ELSE
  145.                         DisableItem(myMenus[fileM], fmSave);
  146.  
  147.                     DisableItem(myMenus[editM], undoCommand);
  148.                     
  149.                     IF (theDoc^.theText^^.selEnd - theDoc^.theText^^.selStart) < 0 THEN
  150.                         BEGIN
  151.                             DisableItem(myMenus[editM], cutCommand);
  152.                             DisableItem(myMenus[editM], copyCommand);
  153.                             DisableItem(myMenus[editM], clearCommand);
  154.                             DisableItem(myMenus[editM], cPublisher);
  155.                         END
  156.                     ELSE
  157.                         BEGIN
  158.                             EnableItem(myMenus[editM], cutCommand);
  159.                             EnableItem(myMenus[editM], copyCommand);
  160.                             EnableItem(myMenus[editM], clearCommand);
  161.                             EnableItem(myMenus[editM], cPublisher);
  162.                         END;
  163.  
  164.                     currSection := GetSection(theDoc^.theText^^.selStart,
  165.                                                                         theDoc^.theText^^.selEnd,
  166.                                                                         theDoc);
  167.                     IF (currSection <> NIL) THEN
  168.                         BEGIN
  169.                             DisableItem(myMenus[editM], cPublisher);
  170.                             DisableItem(myMenus[editM], cSubscriber);
  171.                             EnableItem(myMenus[editM],  cOptions);
  172.                             IF currSection^^.fSecthandle^^.kind = stPublisher THEN
  173.                                 SetItem(myMenus[editM], cOptions, 'Publisher Options…')
  174.                             ELSE
  175.                                 SetItem(myMenus[editM], cOptions, 'Subscriber Options…');
  176.                         END
  177.                     ELSE
  178.                         BEGIN
  179.                             EnableItem(myMenus[editM],  cPublisher);
  180.                             EnableItem(myMenus[editM],  cSubscriber);
  181.                             DisableItem(myMenus[editM], cOptions);
  182.                         END;
  183.                 END;
  184.         END;
  185.  
  186.     {$S Main}
  187.  
  188.     PROCEDURE SetUpCursors;
  189.  
  190.         VAR
  191.             hCurs                 : CursHandle;
  192.  
  193.         BEGIN
  194.             hCurs := GetCursor(1);
  195.             editCursor := hCurs^^;
  196.             hCurs := GetCursor(watchCursor);
  197.             waitCursor := hCurs^^;
  198.         END;
  199.  
  200.     {$S Main}
  201.  
  202.     PROCEDURE SetUpMenus;
  203.  
  204.         VAR
  205.             i                         : INTEGER;
  206.  
  207.         BEGIN
  208.  
  209.             myMenus[appleM] := GetMenu(appleID);
  210.             AddResMenu(myMenus[appleM], 'DRVR');
  211.             myMenus[fileM] := GetMenu(fileID);
  212.             myMenus[editM] := GetMenu(editID);
  213.             myMenus[fontM] := GetMenu(fontID);
  214.             AddResMenu(myMenus[fontM], 'FONT');
  215.             myMenus[sizeM]  := GetMenu(sizeID);
  216.             myMenus[styleM] := GetMenu(styleID);
  217.  
  218.             FOR i := appleM TO kLastMenu DO
  219.                 InsertMenu(myMenus[i], 0);
  220.  
  221.             SetItemStyle(myMenus[styleM], cPlain, []);
  222.             SetItemStyle(myMenus[styleM], cBold, [bold]);
  223.             SetItemStyle(myMenus[styleM], cItalic, [italic]);
  224.             SetItemStyle(myMenus[styleM], cUnderline, [underline]);
  225.             SetItemStyle(myMenus[styleM], cOutline, [outline]);
  226.             SetItemStyle(myMenus[styleM], cShadow, [shadow]);
  227.             SetItemStyle(myMenus[styleM], cCondense, [condense]);
  228.             SetItemStyle(myMenus[styleM], cExtEND, [extEND]);
  229.  
  230.             SetShortMenus;
  231.         END;
  232.  
  233.     PROCEDURE DoFile(theItem: INTEGER);
  234.  
  235.         VAR
  236.             alertResult     : INTEGER;
  237.             theDoc                : DPtr;
  238.             theFSSpec         : FSSpec;
  239.             fileErr             : OSErr;
  240.             thePSetup     : TPrint;
  241.             myErr         : OSErr;
  242.  
  243.         BEGIN
  244.             CASE theItem OF
  245.                 fmNew: IssueAENewWindow;
  246.  
  247.                 fmOpen:
  248.                     IF (GetFile(theFSSpec)=noErr) THEN
  249.                         fileErr := IssueAEOpenDoc(theFSSpec);
  250.  
  251.                 fmClose: IssueCloseCommand(FrontWindow);
  252.  
  253.                 fmSave,
  254.                 fmSaveAs:
  255.  
  256.                     BEGIN
  257.                         theDoc := DPtrFromWindowPtr(FrontWindow);
  258.  
  259.                         IF (theDoc^.everSaved=false) OR (theItem=fmSaveAs) THEN
  260.                             BEGIN
  261.                                 fileErr := GetFileNameToSaveAs(theDoc);
  262.                                 IF (fileErr<>noErr) AND (fileErr<>userCanceledErr) THEN
  263.                                     FileError('error saving ', theDoc^.theFileName)
  264.                                 ELSE
  265.                                     fileErr := IssueSaveCommand(theDoc^.theWindow, @theDoc^.theFSSpec);
  266.  
  267.                                 IF (fileErr = noErr) THEN
  268.                                     SetWTitle(theDoc^.theWindow, theDoc^.theFSSpec.name);
  269.                             END
  270.                         ELSE
  271.                             fileErr := IssueSaveCommand(theDoc^.theWindow, NIL);
  272.  
  273.                     END;
  274.  
  275.                 fmRevert:
  276.                     BEGIN
  277.                         SetCursor(arrow);
  278.                         theDoc := DPtrFromWindowPtr(FrontWindow);
  279.  
  280.                         ParamText('Revert to the last saved version of ', theDoc^.theFileName, '', '');
  281.                         alertResult := Alert(AdviseAlert, NIL);
  282.                         CASE alertResult OF
  283.                             aaSave:
  284.                                 IF IssueRevertCommand(theDoc^.theWindow) <> noErr THEN
  285.                                     FileError('error reverting ', theDoc^.theFileName);
  286.  
  287.                             OTHERWISE;
  288.                         END;     {of CASE}
  289.                     END;         {fmRevert}
  290.  
  291.                 fmPageSetUp: BEGIN
  292.                                              theDoc := DPtrFromWindowPtr(FrontWindow);
  293.                                              IF DoPageSetup(theDoc) THEN
  294.                                                  BEGIN
  295.                                                      thePSetup := theDoc^.thePrintSetup^^;
  296.                                                      IssuePageSetupWindow(theDoc^.theWindow, thePSetup);
  297.                                                  END;
  298.                                          END;
  299.  
  300.                 fmPrint: IssuePrintWindow(FrontWindow);
  301.  
  302.                 fmQuit : myErr := IssueQuitCommand;
  303.  
  304.             END;                 {of case}
  305.         END;
  306.  
  307.     {$S Main}
  308.  
  309.     PROCEDURE DoCommand(mResult: Longint);
  310.  
  311.         VAR
  312.             theItem             : INTEGER;
  313.             err                     : INTEGER;
  314.             result                : Longint;
  315.             name                    : Str255;
  316.             theDocument     : DPtr;
  317.  
  318.         BEGIN
  319.             theDocument := DPtrFromWindowPtr(FrontWindow);
  320.             
  321.             theItem := LoWord(mResult);
  322.  
  323.             CASE HiWord(mResult) OF
  324.  
  325.                 appleID:
  326.                     IF theItem = aboutItem THEN
  327.                         BEGIN
  328.                             SetCursor(arrow);
  329.                             result := Alert(258, NIL);
  330.                         END
  331.                     ELSE
  332.                         BEGIN
  333.                             GetItem(myMenus[appleM], theItem, name);
  334.                             err := OpenDeskAcc(name);
  335.                             SetPort(FrontWindow);
  336.                         END;
  337.  
  338.                 fileID: DoFile(theItem);
  339.  
  340.                 editID:
  341.                     BEGIN
  342.                         IF SystemEdit(theItem - 1) = FALSE THEN;
  343.  
  344.                         CASE theItem OF
  345.  
  346.                             cutCommand   : IssueCutCommand(theDocument);
  347.  
  348.                             copyCommand  : IssueCopyCommand(theDocument);
  349.  
  350.                             pasteCommand : IssuePasteCommand(theDocument);
  351.  
  352.                             clearCommand : IssueClearCommand(theDocument);
  353.  
  354.                             selectAllCommand :
  355.                                 BEGIN
  356.                                     IF theDocument <> NIL THEN
  357.                                         TESetSelect(0, theDocument^.theText^^.teLength, theDocument^.theText);
  358.                                 END;
  359.  
  360.                             cPublisher : IssueCreatePublisher(theDocument);
  361.  
  362.                             cSubscriber: DoSubscribe(theDocument);
  363.  
  364.                             cOptions   : DoSectionOptions(theDocument);
  365.  
  366.                             cBorders   : IssueShowBorders(theDocument^.theWindow, NOT theDocument^.showBorders);
  367.  
  368.                         END;     {of CASE}
  369.                         ShowSelect(theDocument);
  370.  
  371.                     END;
  372.  
  373.                 fontID: IssueFontCommand(theDocument, theItem);
  374.  
  375.                 sizeID: IssueSizeCommand(theDocument, theItem);
  376.  
  377.                 styleID: IssueStyleCommand(theDocument, theItem);
  378.  
  379.             END;                 {of CASE}
  380.         END;
  381.  
  382.     {$S Main}
  383.  
  384.     PROCEDURE DoMouseDown(myEvent: EventRecord);
  385.  
  386.         VAR
  387.             whichWindow     : WindowPtr;
  388.             p                         : POINT;
  389.             dragRect      : Rect;
  390.             theDoc        : DPtr;
  391.  
  392.         BEGIN
  393.             p := myEvent.where;
  394.             CASE (FindWindow(p, whichWindow)) OF
  395.  
  396.                 inDesk: SysBeep(10);
  397.  
  398.                 inGoAway:
  399.                     IF Ours(whichWindow) THEN
  400.                         IF TrackGoAway(whichWindow, p) THEN
  401.                             IssueCloseCommand(whichWindow);
  402.  
  403.                 inMenuBar:
  404.                     BEGIN
  405.                         SetCursor(arrow);
  406.                         theDoc := DPtrFromWindowPtr(FrontWindow);
  407.                         IF (theDoc <> NIL) THEN
  408.                             BEGIN
  409.                                 SetFontMenu(theDoc);
  410.                                 SetEditMenu(theDoc);
  411.                             END;
  412.  
  413.                         DoCommand(MenuSelect(p));
  414.                         HiliteMenu(0);
  415.                     END;
  416.  
  417.                 inSysWindow: SystemClick(myEvent, whichWindow);
  418.  
  419.                 inDrag:
  420.                     BEGIN
  421.                         dragRect := screenBits.bounds;
  422.                         
  423.                         IF (Ours(whichWindow)) THEN
  424.                             BEGIN
  425.                                 DragWindow(whichWindow, p, dragRect);
  426.                                 (*
  427.                                     As rgnBBox may be passed by address
  428.                                 *)
  429.                                 dragRect := WindowPeek(whichWindow)^.strucRgn^^.rgnBBox;
  430.                                 (*
  431.                                     The windows already there, but still tell
  432.                                     the our AppleEvents core about the move in case
  433.                                     they want to do anything
  434.                                 *)
  435.                                 IssueMoveWindow(whichWindow, dragRect);
  436.                             END;
  437.                     END;
  438.  
  439.                 inGrow: BEGIN
  440.                                     SetCursor(Arrow);
  441.                                     IF (Ours(whichWindow)) THEN
  442.                                         MyGrowWindow(whichWindow, p);
  443.                                 END;
  444.             
  445.                 inZoomIn : DoZoom(whichWindow, inZoomIn, p);
  446.  
  447.                 inZoomOut: DoZoom(whichWindow, inZoomOut, p);
  448.  
  449.                 inContent:
  450.                     IF (whichWindow <> FrontWindow) THEN
  451.                         SelectWindow(whichWindow)
  452.                     ELSE
  453.                         IF (Ours(whichWindow)) THEN
  454.                             DoContent(whichWindow, myEvent);
  455.  
  456.             END;                 {of CASE}
  457.         END;
  458.  
  459.     {$S Main}
  460.  
  461.     FUNCTION GetSleep: Longint;
  462.  
  463.     {get the sleep value}
  464.  
  465.         VAR
  466.             sleep                 : Longint;
  467.             theWindow            : WindowPtr;
  468.             theDoc                : DPtr;
  469.  
  470.         BEGIN
  471.             sleep := MAXLONGINT;
  472.             IF NOT gInBackground THEN
  473.                 BEGIN
  474.                     theWindow := FrontWindow;
  475.                     IF (theWindow <> NIL) THEN
  476.                         BEGIN
  477.                             theDoc := DPtrFromWindowPtr(theWindow);
  478.                             IF (theDoc^.theText^^.selStart = theDoc^.theText^^.selEnd) THEN
  479.                                 sleep := GetCaretTime;
  480.                         END;
  481.                 END;
  482.             GetSleep := sleep;
  483.         END;                     {GetSleep}
  484.  
  485.     {$S Main}
  486.     
  487.     PROCEDURE MainEvent;
  488.  
  489.         VAR
  490.             theDoc                : DPtr;
  491.             myEvent             : EventRecord;
  492.             theChar             : Char;
  493.             err                     : INTEGER;
  494.             theWindow         : WindowPtr;
  495.             activate            : BOOLEAN;
  496.             keyIsOk                : BOOLEAN;
  497.             currSection   : SectHandle;
  498.             
  499.         BEGIN
  500.  
  501.             MaintainCursor; (* TEIdle in here for now *)
  502.             MaintainMenus;
  503.  
  504.             IF WaitNextEvent(everyEvent, myEvent, GetSleep, NIL) THEN
  505.                 BEGIN
  506.                     CASE myEvent.what OF
  507.                         mouseDown: BEGIN
  508.                                                  FlushAndRecordTypingBuffer;
  509.                                                  DoMouseDown(myEvent);
  510.                                              END;
  511.                         keydown, autoKey:
  512.                             BEGIN
  513.                                 theDoc := DPtrFromWindowPtr(FrontWindow);
  514.  
  515.                                 theChar := CHR(BitAnd(myEvent.message, charcodemask));
  516.  
  517.                                 IF BitAnd(myEvent.ModIfiers, CmdKey) = CmdKey THEN
  518.                                     BEGIN
  519.                                         DoCommand(MenuKey(theChar));
  520.                                         HiliteMenu(0);
  521.                                     END
  522.                                 ELSE
  523.                                     IF theDoc^.theText <> NIL THEN
  524.                                         BEGIN
  525.                                             keyIsOk := TRUE;
  526.                                             (*
  527.                                                 don't allow a subscriber to be changed
  528.                                             *)
  529.                                             currSection := GetSection(theDoc^.theText^^.selStart,
  530.                                                                                                 theDoc^.theText^^.selEnd,
  531.                                                                                                 theDoc);
  532.                                             
  533.                                             IF (currSection <> NIL) THEN
  534.                                                 IF (currSection^^.fSecthandle^^.kind = stSubscriber) THEN
  535.                                                     keyIsOk := KeyOKinSubscriber(theChar);                                                    
  536.                                             
  537.                                             IF keyIsOK THEN
  538.                                                 BEGIN
  539.                                                     
  540.                                                     DoTEKeySectionRecalc(theDoc, theChar);
  541.                                                     
  542.                                                     AddKeyToTypingBuffer(theDoc, theChar);
  543.                                                     
  544.                                                     TEKey(theChar, theDoc^.theText);
  545.                                                     AdjustScrollbars(theDoc, FALSE);
  546.                                     
  547.                                                     ShowSelect(theDoc);
  548.                                                     
  549.                                                     theDoc^.dirty := TRUE;
  550.                                                 END;
  551.                                         END;
  552.                             END;
  553.  
  554.                         activateEvt:
  555.                             BEGIN
  556.                                 activate := (BitAnd(myEvent.ModIfiers, ActiveFlag) <> 0);
  557.                                 theWindow := WindowPtr(myEvent.message);
  558.                                 DoActivate(theWindow, activate);
  559.                             END;
  560.  
  561.                         updateEvt:
  562.                             BEGIN
  563.                                 theDoc := DPtrFromWindowPtr(WindowPtr(myEvent.message));
  564.                                 DoUpdate(theDoc);
  565.                             END;
  566.  
  567.                         kHighLevelEvent: BEGIN
  568.                                                              FlushAndRecordTypingBuffer;
  569.                                                            DoAppleEvent(myEvent);
  570.                                                          END;
  571.  
  572.                         kOSEvent:
  573.                             CASE BAnd(BRotL(myEvent.message, 8), $FF) OF {high byte of message}
  574.                                 kSuspENDResumeMessage:
  575.                                     BEGIN
  576.                                         gInBackground := BAnd(myEvent.message, kResumeMask) = 0;
  577.                                         DoActivate(FrontWindow, NOT gInBackground);
  578.                                     END;
  579.                             END;
  580.                     END;
  581.                 END;             {of CASE}
  582.         END;
  583.  
  584.     {$S Main}
  585.  
  586.     PROCEDURE DoSVEdit;
  587.  
  588.         VAR
  589.             err                     : OSErr;
  590.             result                : INTEGER;
  591.  
  592.         BEGIN
  593.  
  594.             InitGraf(@thePort);
  595.             InitFonts;
  596.             FlushEvents(everyEvent, 0);
  597.             InitWindows;
  598.             InitMenus;
  599.             TEInit;
  600.             InitDialogs(NIL);
  601.             InitCursor;
  602.  
  603.             MaxApplZone;
  604.             SetUpCursors;
  605.  
  606.             SetUpMenus;
  607.  
  608.             gWCount      := 0;
  609.             gNewDocCount := 0;
  610.             gQuitting    := FALSE;
  611.             gFontMItem   := 0;
  612.  
  613.             {initialise the global functionality booleans, so we can run under both}
  614.             {6.0x and 7.0}
  615.  
  616.             gGestaltAvailable          := FALSE;
  617.             gAppleEventsImplemented    := FALSE;
  618.             gAliasManagerImplemented   := FALSE;
  619.             gEditionManagerImplemented := FALSE;
  620.             gOutlineFontsImplemented   := FALSE;
  621.  
  622.             {check environment checks to see if we are running 7.0}
  623.             IF NOT CheckEnvironment THEN
  624.                 BEGIN
  625.                     SetCursor(arrow);
  626.                     {pose the only 7.0 alert}
  627.                     result := Alert(302, NIL);
  628.                     Exit(DoSVEdit);
  629.                 END;
  630.  
  631.             err := InitEditionPack;
  632.             IF err <> noErr THEN
  633.                 BEGIN
  634.                     ShowError('InitEditionPack', err);
  635.                     gQuitting := TRUE;
  636.                 END;
  637.  
  638.             err := AEObjectInit;
  639.             IF err <> noErr THEN
  640.                 BEGIN
  641.                     ShowError('AEObjectInit', err);
  642.                     gQuitting := TRUE;
  643.                 END;
  644.  
  645.             InitAppleEvents;
  646.  
  647.             err := PPCInit;
  648.             IF err <> noErr THEN
  649.                 BEGIN
  650.                     ShowError('PPCInit', err);
  651.                     gQuitting := TRUE;
  652.                 END;
  653.  
  654.             WHILE NOT gQuitting DO
  655.                 MainEvent;
  656.  
  657.         END;
  658.  
  659.     BEGIN
  660.         {the main routine starts here}
  661.         DoSVEdit;
  662.     END.
  663.